/*package com.broada.apm.util;
package com.broada.apm.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import junit.framework.Assert;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.broada.apm.entity.Application;
import com.broada.apm.entity.Relation;
import com.broada.apm.entity.Service;
import com.broada.apm.indicator.api.ApmClientFactory;
import com.broada.apm.indicator.api.PersistanceService;
import com.broada.apm.indicator.api.Resource;
import com.broada.apm.logic.ResourceLogic;
import com.broada.apm.logic.impl.ResourceLogicImpl;

public class ApplicationData {
	private static ResourceLogic resourceLogic = null;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		resourceLogic = new ResourceLogicImpl();
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
		resourceLogic = null;
	}


	@Test
	public void saveObjectByBatch() {
		List<Resource> resource = resourceLogic.queryResource();
		if(resource == null || resource.size()<=0){
			Assert.assertEquals("resource获取失败", resource);
		}else{
			String[] appids = new String[] { resource.get(0).getId()};
			String[] nodeids = new String[]{resource.get(1).getId(),resource.get(2).getId(),resource.get(3).getId()};
			PersistanceService persistanceService = ApmClientFactory.getApmClient().getPersistanceService();
			for (int i = 0; i < appids.length; i++) {
				List nodes = new ArrayList();
				Application app = new Application();
				app.setStatus(1);
				app.setSystemCode("syscode" + i + 1);
				app.setSystemName("负载均衡" + i);
				app.setTime(new Date());
				app.setSystemId(appids[i]);
				Service cluster = new Service();
				cluster.setServiceId(nodeids[0]);
				cluster.setServiceName("前端WEB服务器" + i);
				cluster.setIp("192.168.22.28");
				cluster.setPort("8080");
				cluster.setServiceCode("code1");
				persistanceService.saveObject(Service.class.getName(), cluster.getId(), cluster);
				Service cluster1 = new Service();
				cluster1.setServiceId(nodeids[1]);
				cluster1.setServiceName("后端tomcat服务器" + i);
				cluster1.setIp("192.168.22.21");
				cluster1.setPort("8888");
				cluster1.setServiceCode("code2");
				persistanceService.saveObject(Service.class.getName(), cluster1.getId(), cluster1);
				Service cluster2 = new Service();
				cluster2.setServiceId(nodeids[2]);
				cluster2.setServiceName("后端数据库服务器" + i);
				cluster2.setIp("192.168.22.20");
				cluster2.setPort("1111");
				cluster2.setServiceCode("code3");
				persistanceService.saveObject(Service.class.getName(), cluster2.getId(), cluster2);
				cluster.setServiceId(cluster.getServiceId());
				cluster1.setServiceId(cluster1.getServiceId());
				cluster2.setServiceId(cluster2.getServiceId());
				nodes.add(cluster);
				nodes.add(cluster1);
				nodes.add(cluster2);
				app.setNodeIds(new String[] { cluster.getId(), cluster1.getId(), cluster2.getId() });
				Relation relation = null;
				List<Service> list = new ArrayList<Service>();
				list.add(cluster);
				list.add(cluster1);
				list.add(cluster2);
				List<Relation> relationList = new ArrayList<Relation>();
				String[] relationsIds = new String[list.size()-1];
				for (int j = 1; j < list.size(); j++) {
					relation = new Relation();
					relation.setRelationId("a" + i + j);

					relation.setFrom(list.get(j - 1).getId());
					relation.setTo(list.get(j).getId());
					persistanceService.saveObject(Relation.class.getName(), relation.getId(), relation);
					relationList.add(relation);
					relation = null;
					relationsIds[j-1]=("a"+i+j);
				}
				list = null;
				app.setRelationIds(relationsIds);
				persistanceService.saveObject(Application.class.getName(), app.getSystemId(), app);
			}
		}
	}
}
*/